Dnsmasq : Install
2017/07/06 |
Install Dnsmasq which is the lightweight DNS forwarder and DHCP Server Software.
|
|
[1] | Install Dnsmasq. |
root@dlp:~# apt -y install dnsmasq resolvconf
|
[2] | Configure Dnsmasq. |
root@dlp:~#
vi /etc/dnsmasq.conf # line 19: uncomment (never forward plain names) domain-needed # line 21: uncomment (never forward addresses in the non-routed address spaces) bogus-priv # line 53: uncomment (query with each server strictly in the order in resolv.conf) strict-order # line 67: add if you need # query the specific domain name to the specific DNS server # the example follows means query [server.education] domain to the [10.0.0.10] server
server=/server.education/10.0.0.10
# line 135: uncomment (add domain name automatically) expand-hosts # line 145: add (define domain name)
domain=srv.world
systemctl restart dnsmasq |
[3] | For DNS records, add them in /etc/hosts.Then, Dnsmasq will answer to queries from clients. By the way, when Dnsmasq is running, fixed value "127.0.0.1" is added in /etc/resolv.conf and also the value of "dns-nameservers" in /etc/network/interfaces is added and managed in /var/run/dnsmasq/resolv.conf. |
root@dlp:~#
vi /etc/hosts # add records 10.0.0.30 dlp.srv.world dlproot@dlp:~# systemctl restart dnsmasq |
[4] | Verify to resolve Name or IP address from a client in internal network. |
root@desktop:~#
vi /etc/network/interfaces # change DNS setting to Dnsmasq Server
dns-nameservers
10.0.0.30
root@desktop:~#
root@desktop:~# systemctl restart ifup@ens3 resolvconf
dig dlp.srv.world. ; <<>> DiG 9.10.3-P4-Debian <<>> dlp.srv.world. ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23139 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;dlp.srv.world. IN A ;; ANSWER SECTION: dlp.srv.world. 0 IN A 10.0.0.30 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Fri Jul 07 16:38:52 JST 2017 ;; MSG SIZE rcvd: 58root@desktop:~# dig -x 10.0.0.30 ; <<>> DiG 9.10.3-P4-Debian <<>> -x 10.0.0.30 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2333 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;30.0.0.10.in-addr.arpa. IN PTR ;; ANSWER SECTION: 30.0.0.10.in-addr.arpa. 0 IN PTR dlp.srv.world. ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Fri Jul 07 16:39:26 JST 2017 ;; MSG SIZE rcvd: 78 |